package tjs.study.mini.mybatismini;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import tjs.study.mini.mybatismini.config.annotion.MiniBatisMapperScanner;
import tjs.study.mini.mybatismini.entity.TjsUser;
import tjs.study.mini.mybatismini.mapper.MyTjsUserMapper;
import tjs.study.mini.mybatismini.mapper.MyTjsUserMapperImpl;
import tjs.study.mini.mybatismini.simpleAop.EnableAopMiniBatisMapperScanner;

/**
 * @author nicky
 * @date 2021/9/1 下午5:45
 */
@SpringBootApplication
@MiniBatisMapperScanner({"tjs.study.mini.mybatismini.mapper"})//使用FactoryBean的代理形式实现
@EnableAopMiniBatisMapperScanner//使用springaop的代理形式实现
public class DoTest implements CommandLineRunner {

    @Autowired(required = false)
    MyTjsUserMapper myTjsUserMapper;
    @Autowired(required = false)
    MyTjsUserMapperImpl myTjsUserMapperImpl;

    public static void main(String[] args) {
        SpringApplication.run(DoTest.class, args);
    }

    @Override
    public void run(String... args) {
        if (myTjsUserMapper != null) {
            TjsUser tjsUser1 = myTjsUserMapper.findByState("CA");
            System.out.println("myTjsUserMapper :" + tjsUser1.toString());
        }

        if (myTjsUserMapperImpl != null) {
            TjsUser tjsUser2 = myTjsUserMapperImpl.findByStateImpl("CA");
            System.out.println("myTjsUserMapperImpl :" + tjsUser2.toString());
        }
    }
}
